const TOKEN = 'fake';
export default async (url, options) => {
  try {
    let res = await fetch(url, {
      ...options,
      headers: {
        'token': TOKEN
      }
    });
    let {code, data, desc} = await res.json();
    if (code === '0') {
      // 成功获取数据
      return JSON.parse(data);
    } else {
      // 失败
      throw desc;
    }
  } catch (e) {
    console.error(e)
    throw e;
  }
}
